package main

import (
	"fmt"
	"github.com/gomodule/redigo/redis"
)

func main() {
	conn, err := redis.Dial("tcp", "192.168.3.108:6379")
	if err != nil {
		fmt.Println("连接Redis ERROR:", err)
		return
	}
	fmt.Println("连接Redis 成功:", conn)
	defer conn.Close()

	resPush, err := conn.Do("lpush", "names", "Clark", "Lois", "Kara")
	if err != nil {
		fmt.Println("Push Redis ERROR:", err)
		return
	}
	fmt.Println("Redis MSet:", resPush)

	for {
		resPop, err := redis.String(conn.Do("lpop", "names"))
		if err != nil {
			if err == redis.ErrNil {
				fmt.Println("队列已经取完:", err)
				break
			} else {
				fmt.Println("Pop Redis ERROR:", err)
				return
			}
		}
		fmt.Println("Redis lpop:", resPop)
	}
}